package com.ruoyi.common.config;

import cn.hutool.core.collection.CollUtil;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.List;

@Data
@Configuration
@ConfigurationProperties(prefix = "data-table")
public class DataTableConfig {
    private String code;
    private String name;
    private String url;
    private String account;
    private String password;
    private List<Api> apiList;

    public Api getApiByCode(String code) {
        return CollUtil.findOne(apiList, api -> code.equals(api.getCode()));
    }

    @Data
    public static class Api {
        private String code;
        private String name;
        private String url;
        private String secretKey;
    }
}
